<template>
  <view v-if="!isLoading">
    <xy-store :store_id="store_id" v-if="store_id!==''" @addCart="addCart"></xy-store>

    <!-- 规格弹窗 -->
    <xy-goods-sku
        v-if="showSku && goods.id"
        v-model="showSku"
        :goodsInfo="goods"
        :buyType="buyType"
        :goodsType="goodsType"
        :default-buy-num="1"
    />
    <cart-num-view/>
  </view>
</template>

<script>
import { mapState,mapActions } from 'vuex';
import xyStore from "@/components/xy-store/index.vue";
import xyGoodsSku from "@/components/xy-goods/sku.vue";
import CartNumView from "@/components/xy-goods/cart_num_view.vue";

export default {
  components: {CartNumView, xyGoodsSku, xyStore},
  data() {
    return {
      isLoading:true,
      store_id : '',

      goods:{},
      showSku:false,
      buyType: 'sku',
      goodsType: 'goods',
      currentSkuText:'',
      showShare:false
    };
  },
  async onLoad(options) {
    var that = this;
    if(options){
      this.store_id = options.id;
    }
    that.loadData();
  },
  computed: {
    ...mapState(['common','user','cart'])
  },
  methods: {
    async loadData(){
      this.isLoading = false;
    },
    // 加入购物车
    addCart(item) {
      console.log(item)
      if (this.user.isLogin) {
        this.goods = item;
        this.buyType = 'cart';
        this.showSku = true;
      } else {
        this.$xyfun.toLogin();
      }
    },
  }
}
</script>

<style lang="scss">

</style>
